﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed
#pragma once
#include "GcmpModelInterface.h"
#include "IObject.h"
#include "OwnerPtr.h"
#include <set>

namespace gcmp
{
    class ElementId;
    struct ElementIdHash;
    class IDocument;

    /// \brief 复制上下文
    FINAL_INTERFACE class GCMP_MODEL_INTERFACE_EXPORT ICopyContext : IObject
    {
    public:
        // 临时性接口，因GBMP实现剪切板时需要去掉所有的非接口调用而暴露，不确定最终是否暴露 
        /// \brief 创建一个复制上下文
        ///
        /// \param copiedElement 所有需要被拷贝的Elements的Id集合
        /// \param modelViewId 拷贝得到的Element所属的ModelView的ElementId
        /// \return 返回创建出的复制上下文
        static OwnerPtr<ICopyContext> Create(const std::unordered_set<ElementId, ElementIdHash> & copiedElement, ElementId modelViewId = ElementId::InvalidID);

    public:
        /// \brief 是否是需要被拷贝的Element的Id
        ///
        /// \return bool 是返回true；不是返回false
        virtual bool IsCopyingElement(const ElementId & elementId) const = 0;

        /// \brief 获取所有的需要被拷贝的Elements的Id
        ///
        /// \return const std::unordered_set<ElementId, ElementIdHash> & 返回的所有需要被拷贝的Elements的Id
        virtual const std::unordered_set<ElementId, ElementIdHash> & GetCopyingElementIds() const = 0;

        /// \brief 深拷贝
        ///
        /// \return OwnerPtr<ICopyContext> 拷贝出的复制上下文
        virtual OwnerPtr<ICopyContext> Clone(void) const = 0;

        /// \brief 添加需要被拷贝的Elements的Id
        ///
        /// \param elementIds 添加的Elements的Id
        /// \return void
        virtual void InsertElementIds(const std::unordered_set<gcmp::ElementId, ElementIdHash> & elementIds) = 0;

        /// \brief 获取拷贝得到的Element所属的ModelView的ElementId
        ///
        /// \return Element ModelView的ElementId
        virtual ElementId GetModelViewId() const = 0;

    public:
        /// \brief 析构函数
        virtual ~ICopyContext(void) = 0;
    };
}

